package com.xhwl.logistics.service.business;

import com.xhwl.logistics.bo.VehicleCarChargeBO;
import com.xhwl.logistics.bo.VehicleCarChargeInfoBO;
import com.xhwl.logistics.bo.VehicleParkingLotSecondBO;
import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import com.xhwl.logistics.bo.input.QueryVehicleCarChargeBO;
import com.xhwl.logistics.component.LookupVehicleParkingLotHandler;
import com.xhwl.logistics.service.impl.VehicleParkingLotServiceImpl;
import com.xhwl.logistics.service.impl.redis.VehicleIntegratedConfigRedisServiceImpl;
import com.xhwl.logistics.strategy.IVehicleParkingLotCarChargeHandler;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

//@Service
public class VehicleCarChargeBusinessService {

    @Autowired
    private VehicleIntegratedConfigRedisServiceImpl vehicleIntegratedConfigRedisService;

    @Autowired
    private LookupVehicleParkingLotHandler lookupVehicleParkingLotHandler;

    @Autowired
    private VehicleParkingLotServiceImpl vehicleParkingLotService;

    public VehicleCarChargeBO carCharge(QueryVehicleCarChargeBO queryVehicleCarChargeBO) {
        Integer projectId = queryVehicleCarChargeBO.getProjectId();

        VehicleParkingLotSecondBO vehicleParkingLotSecondBO = vehicleParkingLotService.queryParkingLot(projectId, queryVehicleCarChargeBO.getParkingLotName());

        VehicleIntegratedConfigBO vehicleIntegratedConfigBO = vehicleIntegratedConfigRedisService.queryIntegratedConfigByProjectId(projectId);

        Integer productId = vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProductId();
        IVehicleParkingLotCarChargeHandler vehicleParkingLotCarChargeHandler = lookupVehicleParkingLotHandler.lookForCarChargeHandler(productId);
        List<VehicleCarChargeInfoBO> vehicleCarChargeInfoBOList = vehicleParkingLotCarChargeHandler.carCharge(vehicleIntegratedConfigBO, queryVehicleCarChargeBO);

        return new VehicleCarChargeBO(vehicleParkingLotSecondBO.getParkingLotName(), vehicleCarChargeInfoBOList);
    }

}
